import http from './http'

export default {
  getArticles ({ gid, page = 0, ...params }) {
    let q = http.buildQuery(params)
    return http.get(`api/article?_format=json&gid=${gid}&page=${page}&${q}`)
  },
  getArticleDetail (id) {
    return http.get(`api/article/${id}?_format=json`)
  },
  postArticle (data) {
    return http.post(`api/article`, data)
  },
  patchArticle ({id, ...data}) {
    return http.patch(`api/article/${id}`, data)
  },
  deleteArticle (id) {
    return http.delete(`api/article/${id}`)
  },
  getArticleLinkDetail (id) {
    return http.get(`api/article-link/${id}?_format=json`)
  },
  postArticleLink (data) {
    return http.post(`api/article-link`, data)
  },
  patchArticleLink ({ id, ...data }) {
    return http.patch(`api/article-link/${id}`, data)
  },
  deleteArticleLink (id) {
    return http.delete(`api/article-link/${id}`)
  },

  getDownload (id) {
    return http.get(`api/download/${id}?_format=json`)
  },
  postDownload (data) {
    return http.post(`api/download`, data)
  },
  patchDownload ({ id, ...data }) {
    return http.patch(`api/download/${id}?_format=json`, data)
  }
}
